define(['hr.common'
, 'app/mdSheQuHospitalBase/bill/bill.model'
, 'app/mdSheQuHospitalBase/stock/stock.model'
], function(common
, Bill
, Stock
){
    function InitModel(){
        var p = {
            url: '/sale/findAllByPage',
            param: '',
            //场景一：columns和operation中width字段值使用百分比，其总和为100%；
            //场景二：columns和operation中width字段值用固定像素值，比如'50px'
            columns: [
                [
                    {id: 'buyQuantity', width: '17%', text: '购买数量'},
                    {id: 'unitPrice', width: '17%', text: '单价'},
                    {id: 'receiveTotal', width: '17%', text: '总应收'},
                    {id: 'bill.billName', width: '17%', text: '账单'},
                    {id: 'stock.stockNum', width: '17%', text: '进货'}
                ]
            ],
            operation: [
                {width: '5%',icon: 'icon-search',text: '详细', clickOperations: 'showData'},
                {width: '5%',icon: 'icon-pencil',text: '修改', clickOperations: 'updateData'},
                {width: '5%',icon: 'icon-cancel-2',text: '删除', clickOperations: 'deleteData'}
            ],
            pageItem: {'id': '10', 'text': '10'},
            title: '销售表列表'
        };
        var tableModel = common.createTableModel(p);
        var model  = {
            searchModel: {
                buyQuantity: ko.observable(''),
                unitPrice: ko.observable(''),
                receiveTotal: ko.observable(''),
                bill: ko.observable(new Bill().dialogModel.billModel),
                stock: ko.observable(new Stock().dialogModel.stockModel)
            },
            tableModel: tableModel,
            dialogModel: {
                saleModel: {
                    id: ko.observable(''),
                    buyQuantity: ko.observable(''),
                    unitPrice: ko.observable(''),
                    receiveTotal: ko.observable(''),
                    bill: ko.observable(new Bill().dialogModel.billModel),
                    stock: ko.observable(new Stock().dialogModel.stockModel)
                    /*
                    通过extend方法，添加对该字段的验证规则，下面示例表示，content字段必填且最大长度为20
                    content: ko.observable().extend({
                        required: {
                            message:'字典名称不允许为空'
                        },
                        maxLength: {
                            params: 20,
                            message:'字典说明长度不允许超过{0}'
                        }
                    })
                    */
                }
                , billArray: ko.observableArray()
                , stockArray: ko.observableArray()
            }
        };
        return model;
    }
    return InitModel;
});